#include<iostream>
#include<queue>
const int N = 1e6 + 10;
int cnt[N];
int kinds;
using namespace std;
typedef pair<int, int> PII;
int main()
{
	queue<PII> q;
	int n;cin >> n;
	while (n--)
	{
		int t, k;cin >> t >> k;
		for (int i = 1; i <= k; i++)
		{
			int x;cin >> x;
			q.push({ t,x });
			if (cnt[x]++ == 0) kinds++;
		}
		while (q.size() && q.back().first - q.front().first >= 86400)
		{
			int t = q.front().second;q.pop();
			if (cnt[t]-- == 1) kinds--;
		}
		cout << kinds << endl;
	}
	return 0;
}